<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>startWithAndEndWith</title>
</head>
<body>
  <script>
    //判断字符串是否在原字符串的头部
    let str = 'hello word!';
    let flag = str.startsWith('hello');
    console.log(flag);
    //判断字符串是否在原字符串的尾部
    let flag2 = str.endsWith('!');
    console.log(flag2);
  </script>
</body>
</html>